import 'package:flutter/material.dart';

class RadioDemo extends StatefulWidget {
  RadioDemo({Key key}) : super(key: key);

  _RadioDemoState createState() => _RadioDemoState();
}

class _RadioDemoState extends State<RadioDemo> {
  int _selectitemradioa = 0;
  int _selectitemradioa1 = 1;
  void _handradiochanged(int value) {
    setState(() {
      _selectitemradioa = value;
    });
    print('_selectitemradioa ==$_selectitemradioa');
  }

  void _handradiochanged1(int value) {
    setState(() {
      _selectitemradioa1 = value;
    });
    print('_selectitemradioa1 == $_selectitemradioa1');
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('RadioDemo'),
        elevation: 0.0,
      ),
      body: Container(
        padding: EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text('_selectitemradioa : $_selectitemradioa;'),
            Text('_selectitemradioa1 : $_selectitemradioa1;'),
            SizedBox(
              height: 50.0,
            ),
            // list
            RadioListTile(
              value: 0,
              groupValue: _selectitemradioa,
              onChanged: _handradiochanged,
              activeColor: Colors.black,
              title: Text('option A'),
              subtitle: Text('subtitle option A'),
              secondary: Icon(Icons.filter_1),
              selected: _selectitemradioa == 0,
            ),
            RadioListTile(
              value: 1,
              groupValue: _selectitemradioa,
              onChanged: _handradiochanged,
              activeColor: Colors.black,
              title: Text('option B'),
              subtitle: Text('subtitle option B'),
              secondary: Icon(Icons.filter_2),
              selected: _selectitemradioa == 1,
            ),
            RadioListTile(
              value: 2,
              groupValue: _selectitemradioa,
              onChanged: _handradiochanged,
              activeColor: Colors.black,
              title: Text('option C'),
              subtitle: Text('subtitle option C'),
              secondary: Icon(Icons.filter_3),
              selected: _selectitemradioa == 2,
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Radio(
                  value: 0,
                  groupValue: _selectitemradioa1,
                  onChanged: _handradiochanged1,
                  activeColor: Colors.black,
                ),
                Radio(
                  value: 1,
                  groupValue: _selectitemradioa1,
                  onChanged: _handradiochanged1,
                  activeColor: Colors.black,
                ),
                Radio(
                  value: 2,
                  groupValue: _selectitemradioa1,
                  onChanged: _handradiochanged1,
                  activeColor: Colors.black,
                ),
              ],
            )
          ],
        ),
      ),
    );
  }
}
